﻿<Window x:Class="CurrencyTextBoxExample.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:currency="clr-namespace:CurrencyTextBoxControl;assembly=CurrencyTextBoxControl"
        Title="CurrencyTextBox Example"
        Width="300"
        Height="130"
        ResizeMode="NoResize">
    <Grid Name="LayoutRoot" Margin="5">
        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition />
            <ColumnDefinition />
        </Grid.ColumnDefinitions>

        <currency:CurrencyTextBox Name="myCurrencyTextBox"
                                  Grid.Row="0"
                                  Grid.Column="0"
                                  Grid.ColumnSpan="2"
                                  Margin="5"
                                  VerticalAlignment="Center"
                                  VerticalContentAlignment="Center"
                                  FontFamily="Consolas"
                                  FontSize="24"
                                  Number="{Binding Number,
                                                   UpdateSourceTrigger=PropertyChanged,
                                                   ValidatesOnDataErrors=True}">
            <currency:CurrencyTextBox.Style>
                <Style TargetType="currency:CurrencyTextBox">
                    <Style.Triggers>
                        <Trigger Property="Validation.HasError" Value="True">
                            <Setter Property="FrameworkElement.ToolTip" Value="{Binding RelativeSource={RelativeSource self}, Path=(Validation.Errors).CurrentItem.ErrorContent}" />
                        </Trigger>
                    </Style.Triggers>
                </Style>
            </currency:CurrencyTextBox.Style>
        </currency:CurrencyTextBox>

        <TextBlock Grid.Row="1"
                   Grid.Column="0"
                   Margin="5"
                   VerticalAlignment="Center"
                   Text="StringFormat:"
                   TextAlignment="Right" />
        <ComboBox Grid.Row="1"
                  Grid.Column="1"
                  Margin="5"
                  HorizontalContentAlignment="Right"
                  FontFamily="Consolas"
                  ItemsSource="{Binding StringFormats}"
                  SelectedItem="{Binding StringFormat,
                                         ElementName=myCurrencyTextBox,
                                         Mode=TwoWay}" />
    </Grid>
</Window>
